package com.bwie.controller;
import com.bwie.Dto.BrandDto;
import com.bwie.domain.Brand;
import com.bwie.service.BrandService;
import com.bwie.service.Impl.BrandServiceImpl;
import com.bwie.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* 品牌表(tb_brand)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/brand")
@Api(tags = "品牌管理")
public class BrandController {
/**
* 服务对象
*/
    @Autowired
    private BrandService brandService;


    @ApiOperation("品牌管理表")
    @PostMapping("getBrandList")
    public R getBrandList(@RequestBody BrandDto brandDto){
        return brandService.getBrandList(brandDto);
    }

    @ApiOperation("创建新品牌")
    @PostMapping("addBrand")
    public R addBrand(@RequestBody Brand brand){
        return brandService.saveBrand(brand);
    }

    @ApiOperation("状态更新")
    @PostMapping("upBrandStatusById")
    public R upBrandStatusById(@RequestBody Brand brand){
        return brandService.upBrandStatusById(brand);
    }

    @ApiOperation("逻辑删除")
    @PostMapping("delupdateById/{brandId}")
    public R delUpdateById(@PathVariable("brandId")Integer brandId){
        return brandService.delUpdateById(brandId);
    }

    @ApiOperation("批量删除操作")
    @PostMapping("batchDelByIds")
    public R batchDelByIds(@RequestBody BrandDto brandDto){
        return brandService.batchDelByIds(brandDto);
    }

    @ApiOperation("品牌字典数据")
    @GetMapping("getBrand")
    public R getBrandList (){
        return brandService.getBrand();
    }
}
